import { Controller, Get, Post, Body, Patch, Param, Delete, Req, Query } from '@nestjs/common';
import { DraftService } from './draft.service';
import { CreateDraftDto } from './dto/create-draft.dto';
import { UpdateDraftDto } from './dto/update-draft.dto';
import { Request } from 'express';

@Controller('draft')
export class DraftController {
  constructor(private readonly draftService: DraftService) { }

  @Post('create')
  async create(@Body() createDraftDto: CreateDraftDto, @Req() req: Request) {
    return await this.draftService.create(createDraftDto, req);
  }

  @Get('all')
  findAll() {
    return this.draftService.findAll();
  }


  @Post('query')
  query(@Body() query: UpdateDraftDto) {
    return this.draftService.query(query);
  }


  @Get('allImage')
  findAllImage(@Query('id') id: string) {
    return this.draftService.findAllImage(+id);
  }

  @Get('detail')
  findOne(@Query('id') id: string) {
    return this.draftService.findOne(+id);
  }

  @Post('update')
  update(@Body() updateDraftDto: UpdateDraftDto) {
    return this.draftService.update(updateDraftDto);
  }

  @Get('delete')
  remove(@Query('id') id: string) {
    return this.draftService.remove(+id);
  }
}
